package com.wnxy.pawnbackgroundsystem.response;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {

    public static final String ADD_FIAIL = "数据添加失败";
    public static final String DELETE_FIAIL = "数据删除失败";
    public static final String UPDATE_FIAIL = "数据修改失败";
    public static final String SELECT_NULL = "未查询到数据";
    public static final String  POWER_LASK = "权限不足";

    private Boolean state;
    private String coed;
    private String massage;
    private T data;

    public static Result runFail(String massage){
        return new Result(false,"4004",massage,null);
    }
    public static Result runFail(String coed,String massage){
        return new Result(false,coed,massage,null);
    }
    public static Result runFail(Boolean bool,String coed,String massage){
        return new Result(bool,coed,massage,null);
    }


    public static Result checkFail(String massage){
        return new Result(false,"3003",massage,null);
    }

    public static Result fail(String coed,String massage){
        return new Result(false,coed,massage,null);
    }

    public static <T> Result<T> runFail(Class<T> t,String massage ,T data){
        return new Result<T>(false,"4004",massage,data);
    }
    public static <T> Result<T> checkFail(Class<T> t,String massage ,T data){
        return new Result<T>(false,"3003",massage,data);
    }
    public static <T> Result<T> fail(Class<T> t,String coed,String massage ,T data){
        return new Result<T>(false,coed,massage,data);
    }
    public static Result success(String massage){
        return new Result(true,"2002",massage,null);
    }
    public static <T> Result<T> success(Class<T> t,String massage ,T data){
        return new Result<T>(true,"2002",massage,data);
    }
    //返回集合泛型
    public static <T> Result<List<T>> success(Class<T> t,List<T> data){
        Result<List<T>> listResult = new Result<List<T>>(true,"2002","查询集合成功",data);
        return listResult;
    }
    //返回分页泛型
    public static <T> Result<IPage<T>> success(Class<T> t, IPage<T> data){
        Result<IPage<T>> iPageResult = new Result<IPage<T>>(true,"2002","分页查询集合成功",data);
        return iPageResult;
    }
}
